home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 666 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. From: phalpern@truffle.ultranet.com (Pablo Halpern)
  2. Message-ID: <313f343f.11284615@news.ultranet.com>
  3. X-Original-Date: Fri, 08 Mar 1996 14:48:29 GMT
  4. Path: in1.uu.net!bounce-back
  5. Date: 08 Mar 96 16:23:23 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: possible extension -- typeof(expr)
  9. Organization: UltraNet Communications, Inc.
  10. References: <199603061757.AA17403@zacatecas.optimum.com>
  11. X-Newsreader: Forte Agent .99d/16.182
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMUBfEOEDnX0m9pzZAQH9cgF/WKvA1UFuQPob98dZbUlspbOmETxrxo6N
  14.     07O+pIiW5KPFKztRU3O3dXwvObV7FhkH
  15.     =+HDE
  16.  
  17. tjb839@zacatecas.optimum.com (Tim Boemker) wrote:
  18.  
  19. >Many times in working with STL I've wished for a new operator to return
  20. >the type of an expression, much the same way sizeof returns the size of
  21. >an expression.
  22. >
  23. >It would allow programs like the following, for example:
  24. >
  25. >   set<foo, less<foo> > s;
  26. >   for(typeof(s)::iterator i = s.begin(); i != s.end(); i++)
  27. >      // do something
  28.  
  29. Actually, I'm surprized that the notation s.iterator is not valid. If
  30. iterator were a static variable or function, instead of a nested class
  31. or typedef, then it WOULD be valid. Has there been any discusion of
  32. permitting this syntax? It seems like it would be easy to implement
  33. (just an extention of the current scope-resolution rules) and would
  34. solve many of the problems that typeof() addresses. The example would
  35. look like this:
  36.  
  37.    set<foo, less<foo> > s;
  38.    for(s.iterator i = s.begin(); i != s.end(); i++)
  39.    //  ^^^^^^^^^^ why isn't this currently valid?
  40.       // do something
  41.  
  42. -------------------------------------------------------------
  43. Pablo Halpern                   phalpern@truffle.ultranet.com
  44.  
  45. I am self-employed. Therefore, my opinions *do* represent 
  46. those of my employer.
  47. ---
  48. [ To submit articles: try just posting with your news-reader.
  49.                       If that fails, use mailto:std-c++@ncar.ucar.edu
  50.   FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html
  51.   Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html
  52.   Comments? mailto:std-c++-request@ncar.ucar.edu.
  53. ]
  54.